﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;

namespace Taurus.Platform.Net
{
    /// <summary>
    /// CookieContainer管理类
    /// 2009-12-15
    /// 吴鸣震
    /// </summary>
    class CookieContainerManager
    {
        private CookieContainerManager() { }
        private static Dictionary<string, CookieContainer> _dic = new Dictionary<string, CookieContainer>();
        private static object lockObj = new object();

        public static CookieContainer GetCookieContainer(string email)
        {
            lock (lockObj)
            {
                if (!_dic.ContainsKey(email))
                {
                    _dic.Add(email, new CookieContainer());
                }
            }            
            return _dic[email];
        }

        public static string GetCookieValue(string email,Uri url, string name)
        {
            CookieContainer cc = GetCookieContainer(email);

            return cc.GetCookies(url)[name].Value;
        }
    }
}
